<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="ajile/com.iskitz.ajile.js?mvcoff,mvcshareoff,refresh"></script>
<script type="text/javascript" src="org.wattdepot.gdata.GDataLoader.js"></script>
<script type="text/javascript" src="org.wattdepot.gdata.makahiki.PowerMonitor.js"></script>
<script type="text/javascript" src="org.wattdepot.gdata.kukuicup.Configuration.js"></script>

<script type="text/javascript">
// Wrap this code in an anonymous self-invoking function to avoid polluting global namespace.
(function() {
  // Get the configuration instance with access to kukuicup data.
  var configuration = new org.wattdepot.gdata.kukuicup.Configuration();
  // A spreadsheet containing dorm energy data.
  var currentPowerUrl = configuration.getCurrentPowerDataUrl();
  // A spreadsheet with baseline data. 
  var baselineDataUrl = configuration.getBaselineDataUrl();
  // How frequently we want the spreadsheets to be refreshed.
  var currentPowerRefreshInterval = 15; 
  var baselineDataRefreshInterval = 0;  // never refresh.
  // Load the visualization API and the spreadsheet data, then call displayDormData.
  var loader = new org.wattdepot.gdata.GDataLoader(displayDormData, 
						   currentPowerUrl, currentPowerRefreshInterval,
						   baselineDataUrl, baselineDataRefreshInterval);  
      
  // Display three gauges
  function displayDormData(currentPowerTable, baselineDataTable) {
    drawPowerMonitor(currentPowerTable, baselineDataTable, configuration.ilima, 'ilima_chart_div');
    drawPowerMonitor(currentPowerTable, baselineDataTable, configuration.mokihana, 'mokihana_chart_div');
    drawPowerMonitor(currentPowerTable, baselineDataTable, configuration.lehua, 'lehua_chart_div');
    var element = document.getElementById('chartdiv');
    element.style.width = configuration.powerMonitorWidth;
    element.style.backgroundColor = configuration.widgetBackgroundColor;
  }

  // Draw a monitor, title, and timestamp for the given dorm. 
  function drawPowerMonitor(currentPowerTable, baselineDataTable, source, id) {
    var monitor = new org.wattdepot.gdata.makahiki.PowerMonitor(configuration);
    monitor.draw(currentPowerTable, baselineDataTable, source, id);
  }
})();
</script>
</head>

<body>
<div id="chartdiv">
  <div id="lehua_chart_div"></div>
  <p>
  <div id="mokihana_chart_div"></div>
  <p>
  <div id="ilima_chart_div"></div>
</div>
</body>
</html>


